package logic

import (
	"context"
	"member_srv/memberclient"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type CreateMemberOrderLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewCreateMemberOrderLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateMemberOrderLogic {
	return &CreateMemberOrderLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *CreateMemberOrderLogic) CreateMemberOrder(req *types.CreateMemberOrderrequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	create, err := l.svcCtx.MemberSrv.CreateMemberOrder(l.ctx, &memberclient.CreateMemberOrderRequest{
		UserId:   req.UserId,
		MemberId: req.MemberId,
		PayType:  req.PayType,
	})
	if err != nil {
		return &types.Response{
			Msg:  err.Error(),
			Code: 500,
			Data: nil,
		}, nil
	}
	return &types.Response{
		Msg:  "会员充值创建成功",
		Code: 200,
		Data: create,
	}, nil
}
